package cron

import (
	"context"
	"github.com/golang/protobuf/ptypes/wrappers"
	roleC "kop/modules/role/client"
	"sync/atomic"
	"time"
)

var (
	OnlineNum int32
)

func Cron() {

	go func() {
		for range time.NewTicker(time.Minute).C {

			var minute = time.Now().Minute()
			if minute%5 == 0 {

				_, _ = roleC.RoleService.SaveOnlineNum(context.Background(), &wrappers.Int32Value{Value: atomic.LoadInt32(&OnlineNum)})
			}
		}
	}()
}
